<extend name="./public/frame.html"/>
<block name="content">
    <div class="layui-row">
        <div class="layui-col-xs3">
            <div class="layui-inline">
                <input type="text" class="layui-input date" readonly id="start" placeholder="提现申请时间-起">
            </div>
            <div class="layui-inline">
                <input type="text" class="layui-input date" readonly id="end" placeholder="提现申请时间-止">
            </div>
        </div>

        <div class="layui-col-xs5">
            <div class="layui-row">


                <div class="layui-col-xs2">
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="driver_name" placeholder="司机姓名">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs2">
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="account_number" placeholder="账（卡）号">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-col-xs2">
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" lay-verify="required|title" required placeholder="手机号"  class="layui-input" id="driver_phone">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-col-xs2">
                    <div class="layui-form">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select id="check_status" class="layui-input">
                                    <option value="">审核状态</option>
                                    <volist name="check_status" id="key">
                                        <option value="{$key}">{$check_status[$key]}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-md4 layui-col-lg3">
            <div class="layui-btn-group">
                <button class="layui-btn" data-type="search">搜索</button>
                <button class="layui-btn layui-btn-disabled" data-type="" id="reset">复位</button>
                <!--<a href="javascript:void(0)" class="lea_but" id="batch_check"><button class="layui-btn" style="background-color: #5FB878" data-type="batch_ckeck">批量审核</button></a>
                <a href="javascript:void(0)" class="lea_but" id="config"><button class="layui-btn layui-btn-xs4" style="background-color:#FFB800;"><span style="color:#fff">风控配置</span></button></a>-->
            </div>

        </div>
    </div>

    <table class="layui-table"
           lay-data="{cellMinWidth: 80, height:'auto', url:'{$url}', page: true,limit: 10, id:'cash'}"
           lay-filter="cash">
        <thead>
        <tr>
            <!--<th lay-data="{checkbox:true,fixed: true}"></th>-->
            <th lay-data="{field:'id', width:80,align:'center'}">ID</th>

            <th lay-data="{field:'driver_id', width:80,align:'center'}">司机ID</th>
            <th lay-data="{field:'driver_name', width:120,align:'center'}">姓名</th>
            <th lay-data="{field:'driver_phone', width:150,align:'center'}">手机号</th>
            <th lay-data="{field:'alipay_username', width:150,align:'center'}">支付宝姓名</th>
            <th lay-data="{field:'alipay_account', width:150,align:'center'}">支付宝账号</th>

            <th lay-data="{field:'add_time', width:200, sort: true,align:'center'}">申请时间</th>
            <th lay-data="{field:'money', width:120, sort: true,align:'center'}">提现金额(元)</th>
            <th lay-data="{field:'admin_name', width:100,align:'center'}">审核人员</th>
            <th lay-data="{field:'audit_status', width:100,align:'center', templet: '#checkStatus'}">审核状态</th>
            <th lay-data="{fixed:'right', toolbar: '#barDemo', width:120, align:'center'}">操作</th>
        </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        {{#if(d.audit_status == 0 ){}}
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="single_check">审核</a>
        {{#}else if(d.audit_status == 9){}}
            <!--<a class="layui-btn layui-btn-warm alayui-btn-xs" lay-event="fail_reason" title="">失败原因</a>-->
            <a style="color:red;" title="{{d.remark}}">失败原因</a>
        {{#}}}
    </script>
    <script type="text/html" id="checkStatus">
        {{#if(d.audit_status==0){}}<span style="color: #5FB878">待审核</span>
        {{#}else if(d.audit_status==1){ }}已审核
        {{#}else if(d.audit_status==9){ }}<span style="color: red">不通过</span>
        {{#}else{}}<span style="color: #FFB800">不通过</span>
        {{#}}}
    </script>


    <script type="application/javascript">
        layui.use(['table', 'laydate', 'form'], function () {
            var table = layui.table
                , form = layui.form
                , laydate = layui.laydate;
            lay('.date').each(function () {
                laydate.render({elem: this, type: 'date', trigger: 'click'});
            });

            //点击查看 分控配置
            $(document).on('click', '#config', function(){
                layer.open({
                    type: 2,
                    title: '风控配置项',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['1000px', '65%'],
                    content: '{:url("/admin/driver_wind/wind")}'
                });
            });

            //点击查看 批量审核信息
            $(document).on('click', '#batch_check', function(){
                layer.open({
                    type: 2,
                    title: '批量审核信息',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['1000px', '65%'],
                    content: '{:url("/admin/driver_wind/batchInfo")}',
                    end:function(){
                        parent.window.location.reload();
                    }
                });
            });

            //监听工具条
            table.on('tool(cash)', function (obj) {
                var data = obj.data; //获得当前行数据
                var id = data.id;
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                if (layEvent === 'single_check') {
                    layer.open({
                        type: 2,
                        title: '审核信息查看',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/driver_wind/singleCheck","id=")}' + id //iframe的url
                    });
                }
                if (layEvent === 'fail_reason') {
                    layer.open({
                        type: 2,
                        title: '审核信息查看',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/driver_wind/singleCheck","id=")}' + id //iframe的url
                    });
                }
                if (layEvent === 'config') {
                    layer.open({
                        type: 2,
                        title: '分控配置信息',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['80%', '80%'],
                        content: '{:url("/admin/driver_wind/windConfig")}', //iframe的url
//                        cancel: function (index, layero) {
//                            table.reload('invoice', {url: '/admin/frWind/index'});
 //                       }
                    });
                }

            });

            var active = {
                search: function () {
                    var driver_name = layui.jquery.trim($('#driver_name').val());
                    var driver_phone = layui.jquery.trim($('#driver_phone').val());
                    var account_number = layui.jquery.trim($('#account_number').val());
                    var driver_type = $('#driver_type').val();
                    var check_status = $('#check_status').val();
                    var start = $('#start').val();
                    var end = $('#end').val();
                    var reset = $('#reset');
                    if (driver_name || driver_phone || account_number || driver_type || check_status || start || end) {
                        reset.removeClass('layui-btn-disabled').addClass('layui-btn-normal').data('type', 'reset');
                        table.reload('cash', {
                            url: '/admin/driver_wind/searchIndex',
                            where: {
                                driver_phone: driver_phone,
                                driver_name: driver_name,
                                account_number: account_number,
                                driver_type : driver_type,
                                check_status: check_status,
                                start: start,
                                end: end
                            }
                        });
                    } else {
                        reset.removeClass('layui-btn-normal').addClass('layui-btn-disabled').data('type', '');
                        alert('搜索项不能为空');
                    }
                }
                , reset: function () {
                    var reset = $('#reset');
                    if (reset.data('type') !== '') {
                        table.reload('cash', {
                            url: '/admin/driver_wind/table?action=index', where: {}
                        });
                    }
                    $('.layui-input').each(function () {
                        $(this).val('');
                    });
                    $('.layui-this').each(function () {
                        $(this).removeClass('layui-this');
                    });
                    reset.removeClass('layui-btn-normal').addClass('layui-btn-disabled').data('type', '');
                }
            };

            $('.layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });

    </script>
</block>
